<?php
include_once './BaseService.php';
include_once '../model/db/ProductDAO.php';
include_once '../model/util/Util.php';  

class ProductServices extends BaseService {
	
	public function __construct(){
		parent::__construct();
	 	parent::setTarget($this);	
//	 	$this->log = Plog::factory(__FILE__);	
	}
	
	public function queryAllBySubType(){
		
		$productDAO=new ProductDAO();
		$orderByField="price";
		$asc="asc";
		$orderByField=@$_GET['orderByField'];
		$asc=@$_GET['asc'];
		$type=1;
		$type=@$_GET['type'];
//		echo "type=$type";
		$result = $productDAO->queryAllBySubType($type,$orderByField,$asc);
//		echo Util::toJson($result);
		
		
		if ($result== null) {
//			echo "{row:[]}";	
			echo "{}";
		} else {
//			echo "{row:".Util::toJson($result)."}";	
			echo Util::toJson($result);
		}
		
	}

	
	public function queryPopProudction($type){
		$productDAO=new ProductDAO();
		$type=1;
		$type=@$_GET['type'];
		$result = $productDAO->queryPopProudction($type);
		if ($result== null) {
//			echo "{row:[]}";	
			echo "{}";
		} else {
//			echo "{row:".Util::toJson($result)."}";	
			echo Util::toJson($result);
		}
		
	}
		public function querySpecialPriceProudction($type){
		$productDAO=new ProductDAO();
		$result = $productDAO->querySpecialPriceProudction($type);
		if ($result== null) {
//			echo "{row:[]}";	
			echo "{}";
		} else {
//			echo "{row:".Util::toJson($result)."}";	
			echo Util::toJson($result);
		}
		
	}
	
		public function queryProd_attrByPaId(){
		$pa_id=$_REQUEST["pa_id"];
		$productDAO=new ProductDAO();
//		echo "type=$type";
		$result = $productDAO->queryProd_attrByPaId($pa_id);
//		echo Util::toJson($result);
		
		
		if ($result== null) {
//			echo "{row:[]}";	
			echo "{}";
		} else {
//			echo "{row:".Util::toJson($result)."}";	
			echo Util::toJson($result);
		}
		
	}

}

$service =  new ProductServices();
$service->__call($_GET["action"], null);
//$service->queryTargetAccountMember();
?>